<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/yuedu.css?v=7.0" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<link rel="stylesheet" href="//at.alicdn.com/t/font_862274_kh35wid1hmb.css" />
		<script>
			// 重写注入代码的方法，让注入代码使用此方法时出错
			String.fromCharCode = function(arg) {return true}
		</script>
	</head>
	<style>
		.complain{
			position: fixed;
			right: 10px;
			top: 0px;
		}
		.complain a{
			text-decoration: none;
		}
		.complain a span{
			padding-left: 5px;
			font-size: 1.2rem;
		}
		.iconfont{
			color: gray;
			opacity: 0.6;
		}
		.sung11{
			position: fixed;
			z-index: 9990;
			width: 100%;
			bottom: 0px;
			text-align: center;
			background: #f33b3b;
			padding: 10px 0px;
			display: flex;
			color: #fff;
			justify-content: center;
			align-items: center;
			opacity: 0.7;
		}
		.sung11 a{
			text-decoration: none;
			font-size: 15px;
			color: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-right: 5px;
		}
		.lingqu{
			font-weight: bold;
			font-size: 1.2rem;
			background: #efdbbc;
			border-radius: 2px;
			color: black;
			padding: 5px;
			margin: 0px 5px;
		}
		.sung11 b{
			font-size: 14px;
		}
	</style>
	<body>
		<div class="container">
			<div class="sung11">
				<a href="51huodong2.html?love1"><span>五一特惠，充51元送61元</span></a>
				<a href="51huodong2.html?love1"><span class="lingqu">领取红包</span></a>
				<b>X</b>
			</div>
			<div class="gif">
				<div>
					<div class="gif-img">
						<img src="img/5-121204193Q9-50.gif" />
					</div>
					<p>加载中...</p>
				</div>
			</div>
			<div class="complain">
				<a href="complain.html?lov">
					<i class="iconfont icon-jinggao"></i><span>投诉</span>
				</a>
			</div>
			<div class="content">
				<!--头部菜单栏-->
				<div class="top" style="display: none;">
					<div class="left">
						<a href="javascript:history.back(-1);"><img src="img/20180820130432.png"><span></span></a>
					</div>
					<div class="right">
						<a href="index.html?love2"><img src="img/20180820130414.png"></a>
					</div>
				</div>
				<div class="center">
					<!--小说图片，名称，作者-->
					<div class="shutou">

					</div>
					<!--小说章节内容-->
					<div class="shu">
						<div class="shu_head">
							
						</div>
						<div class="shu_content">

						</div>
						<div class="tuijian">
							<h4>精彩推荐</h4>
							<div class="tui"></div>
						</div>
					</div>
				</div>
				<!--底部菜单栏-->
				<div class="bottom" style="display: none;">
					<div class="mulu">
						<img src="img/20180820131628.png">
						<p>目录</p>
					</div>
					<div class="zihao">
						<img src="img/20180820131639.png">
						<p>字号</p>
					</div>
					<div class="beijing">
						<img src="img/20180820131656.png">
						<p>背景</p>
					</div>
					<div class="shujia">
						<a href="lishi.html">
							<img src="img/20180820131722.png">
							<p>书架</p>
						</a>
					</div>
				</div>
				<div class="gaizihao" style="display: none;">
					<div class="jian">字号 -</div>
					<div class="daxiao">20</div>
					<div class="jia">字号 +</div>
				</div>
				<div class="gaibeijing" style="display: none;">
					<div class="bai"></div>
					<div class="fen"></div>
					<div class="zong"></div>
					<div class="lv"></div>
					<div class="hei"></div>
				</div>
			</div>
			<div class="bag">
				<div class="bag-2">
					<div class="qian">
						<div class="qian_2">今日成功领取<span class="get">21</span>书币</div>
						<div class="qian_3">签到领币成功</div>
						<div>"请明天继续再接再厉呀"</div>
						<div class="zhen">签到完成，朕要继续看书了</div>
						<div>#本周新书#</div>
						<div class="tui"></div>
					</div>
				</div>
			</div>
			<div class="guanzu">
				<div class="guanzu-2">
					<div class="guanzu-tishi">
						<div><span>温馨提示</span></div>
						<div>长按识别作者授权<span>公众号</span>继续阅读</div>
						<div>由于版权问题，<br>请扫下方二维码继续阅读</div>
						<div class="tishi-img"></div>
						<div>长按识别上方二维码</div>
						<div>确定</div>
					</div>
				</div>
			</div>
			<!--<div class="guanzu2">
				<div class="guanzu2-2">
					<div class="guanzu-tishi2">
						<img src="img/1.jpg" />
						<div class="erwei">
							<div class="charu">
								<div class="tishi-img2"></div>
								<div class="zi">
									<p>长按二维码</p>
									<p>继续阅读精彩内容</p>
								</div>
							</div>
							<div class="x">X</div>
						</div>
					</div>
				</div>
			</div>-->
		</div>
	</body>

	<script type="text/javascript" src="js/getUrlParam.js"></script>
	<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="js/local.js" ></script>
	<script>
		(function(){
            //先判断是否为微信浏览器
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                //重写alert方法，alert()方法重写，不能传多余参数
                window.alert = function(name){
                    var iframe = document.createElement("IFRAME");
                    iframe.style.display="none";
                    iframe.setAttribute("src", 'data:text/plain');
                    document.documentElement.appendChild(iframe);
                    window.frames[0].window.alert(name);
                    iframe.parentNode.removeChild(iframe);
                }
            }
        })();
        $(function(){
        	$(".sung11 b").click(function(){
        		$(".sung11").hide();
        	})
        })
	</script>
	<script>
		$(function(){
			var _hmt = _hmt || [];
			(function() {
			  var hm = document.createElement("script");
			  hm.src = "https://hm.baidu.com/hm.js?055cff4356b44984f650fdfa60a0cee6";
			  var s = document.getElementsByTagName("script")[0]; 
			  s.parentNode.insertBefore(hm, s);
			})();
			var i = 0;
			var id = UrlParm.parm("id");
			var shu_head_id = UrlParm.parm("shu_head_id");
			var qiandao = UrlParm.parm("qiandao");
			//跳转目录页面
			$(".mulu").html('<a href="mulu.html?id=' + id + '"><img src="img/20180820131628.png"><p>目录</p></a>');
			//从签到进入
			if(qiandao==1){
				$.ajax({
					type: "get",
					url: host + "/sign-in",
					datatype: "json",
					success: function(data) {
						if(!!data){
							var shubi = data.getCoins;
							$(".get").html(shubi);
							$(".bag").show();
							$(".gif").hide()
							if(shubi==0){
								$(".qian_2").html("签到成功");
								$(".qian_3").html("今日已签到");
							}
						}
					}
				})
			}
			//点击隐藏签到页
			$(".zhen").click(function(){
				$(".bag").hide();
			})
			//点击隐藏关注页
			$(".guanzu-tishi div:nth-child(6)").click(function(){
				$(".guanzu").hide();
			})
//			$(".x").click(function(){
//				$(".guanzu2").hide()
//			})
			//显示菜单栏
			$(".center").click(function() {
				i++;
				if(i == 1) {
					$(".top").show();
					$(".bottom").show();
					$(".gaibeijing").hide();
					$(".gaizihao").hide();
				} else {
					$(".top").hide();
					$(".bottom").hide();
					$(".gaibeijing").hide();
					$(".gaizihao").hide();
					i = 0;
				}
			})
			//显示改变背景框
			$(".beijing").click(function() {
				$(".top").hide();
				$(".bottom").hide();
				$(".gaibeijing").show();
				i = 0;
			})
			var background=localStorage.getItem('background-color');
			$(".center").css("background-color", background);
			if(background=='rgb(0, 0, 0)'){
				$(".shu").css("color", "gray");
			}
			var back='';
			//改变背景
			$(".bai").click(function() {
				$(".center").css("background", "rgb(255, 255, 255)");
				$(".shu").css("color", "black");
				back=$(".center").css("background-color")
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('background-color',back);
				}
			})
			$(".fen").click(function() {
				$(".center").css("background", "rgb(229, 206, 203)");
				$(".shu").css("color", "black");
				back=$(".center").css("background-color")
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('background-color',back);
				}
			})
			$(".zong").click(function() {
				$(".center").css("background", "rgb(239, 219, 188)");
				$(".shu").css("color", "black");
				back=$(".center").css("background-color")
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('background-color',back);
				}
			})
			$(".lv").click(function() {
				$(".center").css("background", "rgb(208, 229, 203)");
				$(".shu").css("color", "black");
				back=$(".center").css("background-color")
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('background-color',back);
				}
			})
			$(".hei").click(function() {
				$(".center").css("background", "rgb(0, 0, 0)");
				$(".shu").css("color", "gray");
				back=$(".center").css("background-color")
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('background-color',back);
				}
			})
			//显示改变字体大小框
			$(".zihao").click(function() {
				$(".top").hide();
				$(".bottom").hide();
				$(".gaizihao").show();
				i = 0;
			})
			var size=localStorage.getItem('size');
			if(size == null){
				size=20
			}
			//字体减小
			var zi = size;
			$(".daxiao").html(zi);
			$(".shu").css("font-size", "" + zi + "px");
			$(".jian").click(function(event) {
				zi--;
				if(zi <= 12) {
					zi = 12;
				}
				$(".shu").css("font-size", "" + zi + "px");
				$(".daxiao").html(zi);
//				$(".gaizihao").show();
				event.stopPropagation();
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('size',zi);
				}
			})
			//字体增加
			$(".jia").click(function(event) {
				zi++;
				if(zi >= 30) {
					zi = 30;
				}
				$(".shu").css("font-size", "" + zi + "px");
				$(".daxiao").html(zi);
//				$(".gaizihao").show();
				event.stopPropagation();
				if (typeof(Storage) !== "undefined") {
			        localStorage.setItem('size',zi);
				}
			})
			//滑动隐藏
			$(window).scroll(function() {
				$(".top").hide();
				$(".bottom").hide();
				$(".gaibeijing").hide();
				$(".gaizihao").hide();
				i = 0;
			})
			//书籍图片，名称，作者
			var Finished;
			$.ajax({
				type: "get",
				url: host + "/book-info?ID=" + id + "",
				datatype: "json",
				success: function(data) {
					if(!!data.book) {
						$(".gif").hide()
						var div = "";
						var name = data.book.Title;
						var Image = data.book.Image;
						var Author = data.book.Author;
						Finished= data.book.Finished;
						document.title = name;
						div += '<img src="' + host + "/" + Image + '">' + '<h3>' + name + '</h3>' + '<p>' + Author + ' 著</p>';
						$(".left span").html(name);
						$(".shutou").html(div);
					}
				}
			})
			//推荐
			var tuijian = "";
			$.ajax({
				type: "get",
				url: host + "/books?Order=admin_rec%20desc&Limit=3&Offset=0",
				datatype: "json",
				success: function(data) {
					if(!!data.list) {
						for(var i = 0, ln = data.list.length; i < ln; i++) {
							var id=data.list[i].ID;
							var name=data.list[i].Title;
							var Image=data.list[i].Image;
							tuijian += '<div><a href="book_details.html?id='+id+'"><img src="'+host+'/'+Image+'"></a><p>'+name+'</p></div>';
						}
						$(".tui").html(tuijian);
					}
				}
			})
			//章节名称
			var next_chapter = function(next) {
				var url = host + "/chapter?ChapterID=" + shu_head_id + "&BookID=" + id;
				var chapterID = 0;
				if(next) {
					url += "&Type=next"
					$(".gif").css("background","none")
					$(".gif").show()
				}
				$.ajax({
					type: "get",
					url: url,
					async:false,
					complete: function(xhr) {
						if(xhr.status===202) {
			                let msg = JSON.parse(xhr.responseText);
			                if(!!msg.MsgID) {
			                	$(".gif").hide()
				                if (msg.MsgID==="8000") {
				                	if(Finished==2){
				                		alert("本书连载中，已看到最新章!")
				                	}else if(Finished==1){
				                		alert("本书已看完!")
				                	}
			                		window.location.href ="end.html?id="+id+"&Finished="+Finished;
				                } else if(msg.MsgID==="8001") {
				                	window.location.href ="/user/pay?insufficient=1";
				                } else if(msg.MsgID === "8003") {
				                	//未关注提示信息显示
				                	$(".guanzu").show();
//				                	$(".guanzu2").show();
				                	$.ajax({
										type: "get",
										url: host + "/wechat/qrcode",
										datatype: "json",
										success: function(data) {
											if(!!data){
												var qrcode = data.qrcode;
												//二维码
												$(".tishi-img").html("<img src="+host+"/"+qrcode+">");
//												$(".tishi-img2").html("<img src="+host+"/"+qrcode+">");
											}
										}
									})
				                }
			                }
				        }
					},
					success: function(data) {
		                if (!!data.redirect) {
		                    location.href = data.redirect;
		                }
						if(!!data.chapter) {
							shu_head_id = data.chapter.ID;
							var name = data.chapter.Title;
							var Content = data.chapter.Content;
							var bookID = data.chapter.BookID;
							chapterID = data.chapter.ID;
							var vip=data.chapter.IsVip;
			
							if(!next){
								$(".shu_head").append(name);
							} else {
								history.replaceState(null, data.chapter.Title, "yuedu.html?id="+data.chapter.BookID+"&shu_head_id="+data.chapter.ID);
							}
							
							//|获取章节内容
							$.ajax({
								type: "get",
								url: host + "/chapter-content?Content=" + Content + "",
								datatype: "json",
								async:false,
								success: function(data) {
									var txt = data.split("\n");
									var div = "";
									for(var i = 0, ln = txt.length; i < ln; i++) {
										div += "<p>" + txt[i] + "</p>";
									}
									if(next){
										$(".shu").append("<div class='shu_head'>" +name + "</div>" + "<div class='shu_content'>" + div + "</div>" +
											"<div class='tuijian'><h4>精彩推荐</h4><div class='tui'>"+tuijian+"</div></div>");
									}else{
										$(".shu_content").html(div);
									}
									_hmt.push(['_setAutoPageview', false]);
									_hmt.push(['_trackPageview', '/book?id=' + bookID]);
									$(".gif").hide()
								}
							})
						}
					}
				})
				return chapterID
			}
			
			next_chapter(false)
			//获取章节内容的id
			var lock = false;
			//滚动到页面底部加载下一章
			$(window).scroll(function() {
				if($(document).scrollTop() >= $(document).height() - $(window).height()) {
					if(!lock) {
						lock = true;
						next_chapter(true)
						lock = false;
					}
				}
			})
		})
	</script>
</html>